const express = require('express');
const router = express.Router();
const authController = require('../controllers/authController');

// 引入限流中间件
let loginLimiter;
try {
  const rateLimit = require('../middleware/rateLimit');
  loginLimiter = rateLimit.loginLimiter;
} catch (error) {
  // 如果未安装express-rate-limit，使用空中间件
  loginLimiter = (req, res, next) => next();
}

// 小程序登录（添加限流）
router.post('/login', loginLimiter, authController.login.bind(authController));

module.exports = router;

